package com.wslNB.goods.controller;

import com.wslNB.entity.Result;
import com.wslNB.entity.StatusCode;
import com.wslNB.goods.service.SpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author wslNB
 * 商品分类
 * @createTime 2020/9/8 22:20
 * @description description
 */
@RestController
@RequestMapping("/spec")
@CrossOrigin
public class SpecController {

    @Autowired
    private SpecService specService;


    /**
     * 根据分类名称查询规格列表
     * @param categoryName
     * @return
     */
    @GetMapping("/categoryName")
    public Result findListByCategoryName(String categoryName){

        try {
            List<Map> listByCategoryName = specService.findListByCategoryName(categoryName);
            return new Result(true,StatusCode.OK,"查询成功",listByCategoryName);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, StatusCode.ERROR,"查询失败");
        }
    }
}
